<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/view/include.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>网上报名-合肥猎头网</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="${contextPath}/view/css/user.css"
	type="text/css" media="all" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<script src="${contextPath}/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
<!--
	var editor;
	function createEditor(languageCode) {
		if (editor) {
			editor.destroy();
		}
		// Replace the <textarea id="content"> with an CKEditor
		// instance, using default configurations.
		editor = CKEDITOR.replace('content', {
			language : languageCode,
		});
	}

	var disDiv;
	function changeType() {
		var type = document.getElementById("qtype").value;
		if (disDiv) {
			disDiv.style.display = 'none';
			disableFormFields(disDiv, false);
		} else {
			disableFormFields(document.getElementById("div_type1"), false);
			disableFormFields(document.getElementById("div_type2"), false);
			disableFormFields(document.getElementById("div_type3"), false);
			// disableFormFields(document.getElementById("div_type4"), false);
			// disableFormFields(document.getElementById("div_type5"), false);
		}
		if (type == '1') {
			disDiv = document.getElementById("div_type1");
		} else if (type == '2') {
			disDiv = document.getElementById("div_type2");
		} else if (type == '3') {
			disDiv = document.getElementById("div_type3");
		} else if (type == '4') {
			disDiv = document.getElementById("div_type4");
		} else if (type == '5') {
			disDiv = document.getElementById("div_type5");
		}
		disDiv.style.display = "inline";
		disableFormFields(disDiv, false);
	}

	function disableFormFields(container, isDisabled) {
		var tagNames = [ "INPUT", "SELECT", "TEXTAREA" ];
		for ( var i = 0; i < tagNames.length; i++) {
			var elems = container.getElementsByTagName(tagNames[i]);
			for ( var j = 0; j < elems.length; j++) {
				elems[j].disabled = isDisabled;
			}
		}
	}
//-->
</script>
</head>
<body>
	<form:form name="questionEditForm" method="post"
		action="${contextPath}/servlet/questionEdit"
		commandName="QuestionEditCommand">
		<form:hidden path="id" />
		<div class="whiteBG">
			<div class="header_logo"></div>
		</div>
		<div class="midBox">
			<div class="midTitle">
				<spring:message code="ui.question.edit.title" />
			</div>
			<div class="cnt">
				<table width="100%" border="0" cellpadding="0" cellspacing="1"
					bgcolor="#E1E1E1">
					<tr bgcolor="#FFFFFF">
						<td valign="top" align="center" height="300"
							style="padding-top: 15px;">
							<table width="80%" border="0" cellpadding="4" cellspacing="1"
								bgcolor="#E1E1E1">
								<tr bgcolor="#f7f7f7">
									<td align="right"><spring:message
											code="ui.question.edit.label.qtype" /><font color="#ff0000">&nbsp;*</font></td>
									<td align="left"><form:select path="qtype"
											onchange="changeType();">
											<form:option value="1">
												<spring:message code="ui.question.edit.option.qtype.1" />
											</form:option>
											<form:option value="2">
												<spring:message code="ui.question.edit.option.qtype.2" />
											</form:option>
											<form:option value="3">
												<spring:message code="ui.question.edit.option.qtype.3" />
											</form:option>
											<%--
										<form:option value="4"><spring:message code="ui.question.edit.option.qtype.4" /></form:option>
										<form:option value="5"><spring:message code="ui.question.edit.option.qtype.5" /></form:option>
										 --%>
										</form:select><font color="#ff0000">&nbsp;&nbsp;<form:errors
												path="qtype" /></font></td>
								</tr>
								<tr bgcolor="#ffffff">
									<td align="right"><spring:message
											code="ui.question.edit.label.category" /><font
										color="#ff0000">&nbsp;*</font></td>
									<td align="left"><form:select path="category.id">
											<form:option value="-1">
												<spring:message code="ui.question.edit.option.category.-1" />
											</form:option>
											<c:forEach items="${categorys}" var="category">
												<form:option value="${category.id }"
													label="${category.name }" />
											</c:forEach>
										</form:select> <font color="#ff0000">&nbsp;&nbsp;<form:errors
												path="category" /></font></td>
								</tr>
								<tr bgcolor="#f7f7f7">
									<td align="right"><spring:message
											code="ui.question.edit.label.status" /><font color="#ff0000">&nbsp;*</font></td>
									<td align="left"><form:select path="status">
											<form:option value="1">
												<spring:message code="ui.question.edit.option.status.1" />
											</form:option>
											<form:option value="-1">
												<spring:message code="ui.question.edit.option.status.-1" />
											</form:option>
										</form:select><font color="#ff0000">&nbsp;&nbsp;<form:errors
												path="status" /></font></td>
								</tr>
								<tr bgcolor="#f7f7f7">
									<td align="right"><spring:message
											code="ui.question.edit.label.content" /><font
										color="#ff0000">&nbsp;*</font></td>
									<td align="left"><form:textarea path="content" cols="50"
											rows="4" /><font color="#ff0000">&nbsp;&nbsp;<form:errors
												path="content" /></font></td>
								</tr>
								<tr bgcolor="#f7f7f7">
									<td align="right"><spring:message
											code="ui.question.edit.label.qkey" /><font color="#ff0000">&nbsp;*</font></td>
									<td align="left" id="key_setting"><c:set var="opsCount"
											value="${fn:length(QuestionEditCommand.questionOptionses)}" />
										<div style="display: none" id="div_type1">
											<table>
												<c:choose>
													<c:when
														test="${QuestionEditCommand.qtype == 1 && opsCount > 0 }">
														<c:forEach
															items="${QuestionEditCommand.questionOptionses }"
															var="option" varStatus="status">
															<tr>

																<td>选项${option.alias }:</td>
																<td><form:radiobutton path="qkey"
																		value="${option.alias }" /></td>
																<td><form:hidden
																		path="questionOptionses[${status.index }].id" /> <form:hidden
																		path="questionOptionses[${status.index }].alias" /> <form:input
																		path="questionOptionses[${status.index }].qoption" /></td>
															</tr>
														</c:forEach>
													</c:when>
													<c:otherwise>
														<c:forEach items="A,B,C,D" var="alias" varStatus="status">
															<tr>
																<td>选项${alias }:</td>
																<td><input type="radio" size="30" name="qkey"
																	value="${alias }" /></td>
																<td><input type="hidden"
																	id="questionOptionses${status.index }.alias"
																	name="questionOptionses[${status.index }].alias" value="${alias }"/><input
																	type="text" size="30"
																	id="questionOptionses${status.index }.qoption"
																	name="questionOptionses[${status.index }].qoption"/></td>
															</tr>
														</c:forEach>
													</c:otherwise>
												</c:choose>
											</table>
										</div>
										<div style="display: none" id="div_type2">
											<table>
												<c:choose>
													<c:when
														test="${QuestionEditCommand.qtype == 2 && opsCount > 0 }">
														<c:forEach
															items="${QuestionEditCommand.questionOptionses }"
															var="option">
															<tr>
																<td>选项${option.alias }:</td>
																<td><input type="checkbox" size="30"
																	name="option2_check" value="${option.alias }" /></td>
																<td><form:hidden
																		path="questionOptionses[${status.index }].id" /> <form:hidden
																		path="questionOptionses[${status.index }].alias" /> <form:input
																		path="questionOptionses[${status.index }].qoption" /></td>
															</tr>
														</c:forEach>
													</c:when>
													<c:otherwise>
														<c:forEach items="A,B,C,D" var="alias">
															<tr>
																<td>选项${alias }:</td>
																<td><input type="checkbox" size="30"
																	name="option2_check" value="${alias }" /></td>
																<td><input type="text" size="30"
																	name="option2_value_${alias }" /></td>
															</tr>
														</c:forEach>
													</c:otherwise>
												</c:choose>
											</table>
										</div>
										<div style="display: none" id="div_type3">
											<table>
												<tr>
													<td><input type="radio" size="30" name="option3_check"
														value="YES" />&nbsp;正确&nbsp;&nbsp;&nbsp;</td>
													<td><input type="radio" size="30" name="option3_check"
														value="NO" />&nbsp;错误</td>
												</tr>
											</table>
										</div> <%-- <div style="display: none" id="div_type4">
											<table>
												<tr>
													<td><input type="text" size="15"
														name="option4_value_0" /></td>
													<td><input type="text" size="15"
														name="option4_value_1" /></td>
												</tr>
												<tr>
													<td><input type="text" size="15"
														name="option4_value_2" /></td>
													<td><input type="text" size="15"
														name="option4_value_3" /></td>
												</tr>
											</table>
										</div>
										<div style="display: none" id="div_type5">
											<textarea rows="4" cols="40" name="option5_value_0"></textarea>
										</div> --%></td>
								</tr>
								<tr bgcolor="#f7f7f7">
									<td align="right"><spring:message
											code="ui.question.edit.label.keydesc" /><font
										color="#ff0000">&nbsp;*</font></td>
									<td align="left"><form:textarea path="keydesc" cols="50"
											rows="4" /><font color="#ff0000">&nbsp;&nbsp;<form:errors
												path="keydesc" /></font></td>
								</tr>
								<tr bgcolor="#f7f7f7">
									<td height="22" colspan="4">
										<div align="center">
											<input type="submit"
												value="<spring:message code="ui.common.button.ok" />"
												name="_target4" />&nbsp;&nbsp; <input type="reset"
												value="<spring:message code="ui.common.button.reset" />" />
											&nbsp;&nbsp;<input type="button"
												value="<spring:message code="ui.common.button.back" />"
												style="width: 50px;"
												onclick="javascript:document.location='/exam/roomList.action'" />
										</div>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</form:form>
	<script type="text/javascript">
	<!--
		changeType();
	//-->
	</script>
</body>
</html>